package com.hotau.member.vo;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.content.Context;

import com.hotau.HotauConstants;

/**
 * 登录用户信息
 * @author liujia (liujia9234@126.com)
 * @data 2011-12-9
 * @version 1.0
 * <ul>
 * 		<li>1.0 创建</li>
 * </ul>
 */
public class User {
	
	public String userCode;
	public String loginType = "0";
	public String loginPwd;
	public String terminalCode;
	public String sign;
	public String memberCode;
	public String realName;
	public String accName;
	public String status;
	public String accStatus;
	public String amount;
	
	
	/**
	 * 检查数据
	 * @return
	 */
	public boolean isCheck(){
		if(isMobileNO(userCode)){
			loginType = "1";
		}
		if(isEmailNO(userCode)){
			loginType = "2";
		}
		if(!loginType.equals("0")){
			return true;
		}
		return false;
		
	}
	
	/**
	 * 登录请求的数据
	 * @return
	 */
	public String getLoginRequestText(Context context){
		StringBuilder sb = new StringBuilder();
		sb.append("Form:userCode="+userCode);
		sb.append(";loginType="+loginType);
		sb.append(";loginPwd="+loginPwd);
		sb.append(";terminalCode=" + HotauConstants.getTerminalCode(context));
		return sb.toString();
	}

	
	/**
	 * 判断是否手机号码
	 * @param mobiles
	 * @return
	 */
	public static boolean isMobileNO(String mobiles){       
		Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");  
		Matcher m = p.matcher(mobiles);        
		return m.matches();        
	} 
	
	/**
	 * 判断是否邮箱
	 * @param mobiles
	 * @return
	 */
	public static boolean isEmailNO(String email){
//		Pattern p = Pattern.compile("\\w+(\\.\\w+)*@\\w+(\\.\\w+)+");
		Pattern p = Pattern.compile("^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+$");
		Matcher m = p.matcher(email);        
		return m.matches();        
	} 
	
}
